javascript replace spaces with dashes

140

javascript replace spaces with dashes -

title = title.replace(/\s/g , "-");

javascript replace all spaces with dashes -

let originalText = 'This is my text';
let dashedText = originalText.replace(/ /g, '-');

replace all spaces with dash in javascript -

title = title.replace(/\s/g , "-");
var html = "<div>" + title + "</div>";
// ...

replace space with hyphen/dash javascript -

const str = "Sonic Free Games";
str = str.replace(/\s+/g, '-').toLowerCase();
console.log(str); // "sonic-free-games"

replace spaces with dashes -

const text = "codetogo saved me tons of time";

text.replace(/ /g, "-");

Comments

Submit
0 Comments